#define _CRT_SECURE_NO_WARNINGS 1
class Solution {
public:
    int getMaxLen(vector<int>& nums) {
        int n = nums.size();
        vector<int> f(n);
        auto g = f;
        if (nums[0] > 0)
        {
            f[0] = 1;
            g[0] = 0;
        }
        else if (nums[0] < 0)
        {
            f[0] = 0;
            g[0] = 1;
        }
        else
        {
            f[0] = g[0] = 0;
        }
        if (n == 1) return f[0];
        int ret = -INT_MAX;
        for (int i = 1;i < n;i++)
        {
            if (nums[i] > 0)
            {
                f[i] = f[i - 1] + 1;
                g[i] = g[i - 1] == 0 ? 0 : g[i - 1] + 1;
            }
            else if (nums[i] < 0)
            {
                f[i] = g[i - 1] == 0 ? 0 : g[i - 1] + 1;
                g[i] = f[i - 1] + 1;
            }
            else
            {
                f[i] = g[i] = 0;
            }
            ret = max(ret, f[i]);
        }
        for (int i = 0;i < n;i++)
        {
            cout << f[i] << " ";
        }
        cout << endl;
        for (int i = 0;i < n;i++)
        {
            cout << g[i] << " ";
        }
        return ret;
    }
};